package com.admin.domain.media;

import com.admin.utils.HaiyinException;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

@ConfigurationProperties(prefix = "uploader")
public class MediaProperties {
    private String prefix = "media-upload";
    private String bucket;
    private String accessKey;
    private String secretKey;
    private String domain;

    public String getLocation() {
        try {
            return String.format("%s/%s", new ClassPathResource("public").getFile().getAbsolutePath(), prefix);
        } catch (IOException e) {
            throw new HaiyinException(e);
        }
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public String getBucket() {
        return bucket;
    }

    public void setBucket(String bucket) {
        this.bucket = bucket;
    }

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

}
